from divisors import divisors

def isperfect(n):
    return sum(divisors(n)) == n

def isabundant(n):
    return sum(divisors(n)) > n

def perfectNrs(limit):
    return [x for x in xrange(1, limit) if isperfect(x)]
    
def abundantNrs(limit):
    return [x for x in xrange(1, limit) if isabundant(x)]

limit = 28123

abnrs = abundantNrs(limit)
print "Got", len(abnrs), "abundant numbers"

nrs = [1] * limit

abnrsLen = len(abnrs)
for i in xrange(0, abnrsLen):
    a = abnrs[i]
    for j in xrange(i, abnrsLen):
        b = abnrs[j]
        abnrsSum = a + b
        if (abnrsSum < limit):
            nrs[abnrsSum] = 0

print sum(x for x in xrange(0, limit) if nrs[x] == 1)
